var mdViewer = {
    template: '#mdViewer',
    data() {
        return {
            mdName: '查看文章',
            sidebarRight: null,
			mdViewerData:null
        }
    },
    beforeDestroy() {
        $("#custom-toc-container").remove();
    },
    mounted() {
        $loading.show('加载中..')
		this.mdViewerData=mapCatch.get('mdViewerData')
        this.mdName = this.mdViewerData.name
        that = this
        this.sidebarRight = $sidebar.fromTemplate('<div id="custom-toc-container">文档添加toc生成目录</div>', {position: 'right'})
        setTimeout(function() {
            $("#overMd").empty();
            that.WatchMd('overMd', that.mdViewerData.data)
        }, 500)
    },
  
    methods: {
        scrolUp() {
            $(".scroll").scrollTop(0);
        },
        onRefresh(done) {
            setTimeout(done, 1000)
        },
        back() {
            this.$router.go(-1)
        },
        openShare(){
            // $toast.show("懒得做");
            data=getAES(this.mdViewerData.objectId)
			this.$router.replace({ path: '/shareMd', query: { data: data }});
        },
        openMenu(){
                this.sidebarRight.toggle()
        },
        WatchMd(id, markdown) {
            editormd.markdownToHTML(id, {
                htmlDecode: true,
                tocContainer : "#custom-toc-container",
                markdown: markdown,
                emoji: true,
				tocm:false,
                taskList: true,
            });
            $loading.hide()
        }
    }
}